/**
 * hoverDuring       鼠标经过的延时时间
outDuring          鼠标移出的延时时间
hoverEvent        鼠标经过执行的方法
outEvent         鼠标移出执行的方法
	$("#headBody #header_menu li.moreLis").hoverDelay({
		hoverEvent:function(target){
			$(this).children('ul').slideDown('slow');
		},
		outEvent:function(target){
			$(this).children('ul').slideUp('fast');
		},
		outDuring:0   //鼠标离开的超时时间
	});
 */
(function($){
    $.fn.hoverDelay = function(options){
        var defaults = {
            hoverDuring: 200,
            outDuring: 200,
            hoverEvent: function(){
                $.noop();//这个函数表示什么也不做
            },
            outEvent: function(){
                $.noop();//这个函数表示什么也不做
            }
        };
        var sets = $.extend(defaults,options || {});
        var hoverTimer=[] ;
        var outTimer=[];
        return $(this).each(function(i){
        	var t = this;
            $(this).hover(function(){
                clearTimeout(outTimer[i]);
                //hoverTimer = setTimeout(sets.hoverEvent, sets.hoverDuring);
                hoverTimer[i] = setTimeout(function(){sets.hoverEvent.apply(t);}, sets.hoverDuring);
            },function(){
                clearTimeout(hoverTimer[i]);
                //outTimer = setTimeout(sets.outEvent, sets.outDuring);
                outTimer[i] = setTimeout(function(){sets.outEvent.apply(t);}, sets.outDuring);
            });
        });
    };
})(jQuery);
